package org.zebra.captcha.mail;

import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import org.zebra.message.MailProperties;

/**
 * @author 张红彬
 */
public interface MailCaptchaTemplateSource {

    default String getMailTitle() {
        return SpringUtil.getBean(MailCaptchaProperties.class).getMailTitle();
    }

    /**
     * @param code           验证码
     * @param expirationTime 分钟
     * @return
     */
    default String getMailContent(String code, int expirationTime) {
        return StrUtil.format(SpringUtil.getBean(MailCaptchaProperties.class).getMailContent(), code, expirationTime);
    }

    default String getMail() {
        return SpringUtil.getBean(MailProperties.class).getFromAddress();
    }
}
